#include "video.h"
#include "Container.h"


int main(void) {
  

	//ge kunt dus zo video's toevoegen. Ge kunt wel maar 1 part per video... 2 parts van dezelfd video = 2x video toevoegen met een ander part 

	try
	{
		av_register_all( );
		container output;

		//video T("test1.wmv");
		//output.AddVideo(T);
		/*video sc1("scene1.avi");
		sc1.SetPart(20, 50);
		output.AddVideo(sc1);
		video sc2("scene2.mov");
		sc2.SetPart(20, 70);
		output.AddVideo(sc2);
		video sc3("scene3.mp4");
		sc3.SetPart(10, 26);
		output.AddVideo(sc3);*/
		video sc4("scene4.wmv");
		sc4.SetPart(60, 80);
		output.AddVideo(sc4);
		/*video sc5("scene5.avi");
		sc5.SetPart(18, 50);
		output.AddVideo(sc5);*/

		output.EnableStreams(true, true);
		output.SetEncoder("testlog.avi",2000000,24,1,12,720,576, 48000, 128000, 2, CODEC_ID_MPEG2VIDEO, CODEC_ID_MP2); //output zetten, de naam, en de resolutie enz...
		output.Process(); //beginnen eraan!
	}
	catch(char * exception)
	{
		printf("Error: %s\n", exception);
	}
	
	return 0;
}


/*

//#include <ffmpeg/avformat.h>
// #include <ffmpeg/avcodec.h>
#include <stdlib.h>
#include <string.h>

extern "C"
{
#include <avcodec.h>
#include <avformat.h>
#include <swscale.h> 
}

 int main ( void )
 {
     // Initialize libavformat and libavcodec and register all codecs and (de)muxers
     av_register_all( );
 
     // We'll use the first argument as the filename for the compressed file
    char *filename = "audio.mp3";

     // Let libavformat determine what codecs best to use for a file with this
     // extension
     AVOutputFormat *fmt = guess_format( NULL, filename, NULL );
 
     // Allocate a context for the muxer
     AVFormatContext *format_context = av_alloc_format_context();
     format_context->oformat = fmt;

    // Add a new stream
    AVStream *audio_stream = av_new_stream(format_context, 0);

    AVCodecContext *audio_codec_context = audio_stream->codec;

     // Select the default codec which was guessed earlier from the extension
     audio_codec_context->codec_id = fmt->audio_codec;
 
     // We're adding a audio stream
     audio_codec_context->codec_type = CODEC_TYPE_AUDIO;
 
     // Some bitrate in bits per second
     audio_codec_context->bit_rate = 64000;
    audio_codec_context->sample_rate = 48000;
     audio_codec_context->channels = 2;
 
     // This is needed even if no parameters are set...
    av_set_parameters(format_context, NULL);
 
    // Find the audiocodec needed to encode our audiostream
    AVCodec *audio_codec = avcodec_find_encoder ( audio_codec_context->codec_id );

     // Make our AVCodecContect use this audiocodec
    avcodec_open ( audio_codec_context, audio_codec );

    // Allocate a buffer to store the encoded sampledata in
    int audio_outbuf_size = 400000;
     uint8_t *audio_outbuf = (uint8_t*)av_malloc( audio_outbuf_size );
 
    // Allocate a buffer to store the original samples in
    // which are read from file
     int samplebuffer_size = audio_codec_context->frame_size * 2 *audio_codec_context->channels;
    int16_t *samples = (int16_t*)av_malloc( samplebuffer_size );
 
     // Open the output file
    url_fopen( &format_context->pb, filename, URL_WRONLY );

     av_write_header( format_context );
 
     FILE *fd = fopen( "audio.pcm", "rb" );
 
     while ( !feof( fd ) ) {
 
         // Read samples from test.raw
         fread( samples, samplebuffer_size, 1, fd );
 
         // Encode the uncompressed samples into the outputbuffer (audio_outbuf)
       int len = avcodec_encode_audio ( audio_codec_context, audio_outbuf, audio_outbuf_size, samples );
         if ( len >= 0 ) {
            // If we got some data, multiplex it
            AVPacket packet;
          av_init_packet( &packet );
           packet.stream_index = audio_stream->index;
          packet.data = audio_outbuf;
           packet.size = len;
           av_write_frame( format_context, &packet );
     }
  }

    av_write_trailer( format_context );

  avcodec_close( audio_codec_context );
    av_free( audio_outbuf);
   av_free( samples );
  av_free( format_context->streams[0] );
    url_fclose( &format_context->pb );
   av_free( format_context );
   fclose( fd );

	 return 0;
}
*/